var app = getApp()
Page({
  data: {
    /** 
        * 页面配置 
        */
    winWidth: 0,
    winHeight: 0,
    // tab切换  
    currentTab: 0,
    userInfo: {},
    logged: false,
    user: {},

  },
  checkTab: function (e) {
    var that = this;
    var inputtitle=wx.getStorageSync("inputtitle");
    var userInfo = wx.getStorageSync("userInfo");  
    console.log("userInfo"+userInfo);
    var inputmessge = wx.getStorageSync("inputmessge");
    if (userInfo == null || userInfo==""){
       wx.showModal({
        title: '提示',
        content: '您没有激活状态，请去激活',
        success: function (res) {
          if (res.confirm) {
            console.log('用户点击确定');
            wx.switchTab({
              url: '../login/login'
            })        
            return;
           
          } else if (res.cancel) {
            console.log('用户点击取消');
            return;
          }
        }
      })  
    }else{
      wx.request({
        url: "https://www.szz5.com/admin/messge",
        data: {
          youwords: inputtitle,
          contact: inputmessge,
          userCardNo: userInfo
          //  code: res.code,
          //  encryptedData: userRes.encryptedData,
          //  iv: userRes.iv
        },
        header: {
          "Content-Type": "application/x-www-form-urlencoded"
        },
        method: 'POST',
        //服务端的回掉
        success: function (result) {
          console.log(JSON.stringify(result));
          wx.showToast({
            title: '反馈成功',
            icon: 'succes',
            duration: 3000,
            mask: true
          })    
          wx.switchTab({
            url: '../index/index'
          }); 

          // data.expireTime = nowDate + EXPIRETIME;
          wx.setStorageSync("userInfo", result.data);
          // userInfo = data;
        }
      })
    }
  },
  inputtitle: function (e) {
    
    console.log("title" + e.detail.value);
    wx.removeStorageSync("inputtitle");
    wx.setStorageSync("inputtitle", e.detail.value);
  },
  inputmessge: function (e) {
    console.log("messge" + e.detail.value);
    wx.removeStorageSync("inputmessge");
    wx.setStorageSync("inputmessge", e.detail.value);
  },

})

